<?php
/*
 * СПВ
 **/
class SP_Form_InputText extends SP_Form_CommonField
{	
	protected $is_password;
	protected $is_hidden;

	public function __construct($attr=null)
	{
		parent::__construct($attr);
		$filter=new SP_Filter_Htmlchars;
		$this->addInputFilter('html_chars', $filter);
	}
	
	public function getHtml()
	{
		$value = ($this->value===null)? $this->default : $this->value;
		$value=$this->filtrateInput($value);
		$type = ($this->is_hidden)? 'hidden' : 'text';
		$type = ($this->is_password)? 'password' : 'text';
		$out='<input type="'.$type.'" name="'.$this->getFullName().'" id="'.$this->generateId().'" value="'.$value.'"'.$this->compileAttr().' />';
		return $out;
	}

	public function getRequestValue()
	{
		$value=parent::getRequestValue();
		$value=trim($value);
		if( empty($value) ) return null;
		return $value;
	}
}